package observer;

import java.util.Observable;
import java.util.Observer;

import GUI.DrawingPanel;

import composite.*;

/**
 * Observer pattern.
 * This observer observes document and draws rootGroup at the panel
 * Look also in DocumentManager(sends notifications)
 */
public class ObserverClassic implements Observer {
	private DrawingPanel drawing_panel;
	
	public ObserverClassic(){
	    // Create an instance of DrawingPanel
	    drawing_panel =  new DrawingPanel();
	}
		
	public void update(Observable arg0, Object arg1) {	
		System.out.println("Observer classic: Document changed!");
		ObjectGroup rootGroup = (ObjectGroup) arg1;
		drawing_panel.setRootGroup(rootGroup);
		drawing_panel.repaint();
	}
	
	public DrawingPanel getDrawing_panel() {
		return drawing_panel;
	}
	public void setDrawing_panel(DrawingPanel drawingPanel) {
		drawing_panel = drawingPanel;
	}
}